WebSocketClientTransport

class WebSocketClientTransport(client: HttpClient, urlString: String?, requestBuilder: HttpRequestBuilder.() -> Unit = {}) : WebSocketMcpTransport(source)

Client transport for WebSocket: this will connect to a server over the WebSocket protocol.

Constructors

Link copied to clipboard
constructor(client: HttpClient, urlString: String?, requestBuilder: HttpRequestBuilder.() -> Unit = {})

Properties

Link copied to clipboard
open override var onClose: () -> Unit?

Callback for when the connection is closed for any reason.

Link copied to clipboard
open override var onError: (Throwable) -> Unit?

Callback for when an error occurs.

Link copied to clipboard
open override var onMessage: suspend (JSONRPCMessage) -> Unit?

Callback for when a message (request or response) is received over the connection.

Link copied to clipboard
protected open override var session: WebSocketSession

The WebSocket session used for communication.

Functions

Link copied to clipboard
open suspend override fun close()

Closes the connection.

Link copied to clipboard
open suspend override fun send(message: JSONRPCMessage)

Sends a JSON-RPC message (request or response).

Link copied to clipboard
open suspend override fun start()

Starts processing messages on the transport, including any connection steps that might need to be taken.